/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Telas;

import java.awt.Toolkit;

/**
 *
 * @author Thalyson
 */
public class Tela_Calc extends javax.swing.JFrame {

    private double Operacao1 = 0.0;
    private double Operacao2 = 0.0;
    private char Operador_Matematico;

    public Tela_Calc() {
        initComponents();
        setSize(262, 260);
        setLocationRelativeTo(null);
        Icon();
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    private void Icon(){
    
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("assistec_icon.png")));
        
    }    

    private void pegarOperador(String Botao) {
        Operador_Matematico = Botao.charAt(0);
        Operacao1 = Operacao1 + Double.parseDouble(tf_calculo.getText());
        tf_calculo.setText("");
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jb_0 = new javax.swing.JButton();
        jb_igual = new javax.swing.JButton();
        jb_mais = new javax.swing.JButton();
        jb_limpar = new javax.swing.JButton();
        jb_1 = new javax.swing.JButton();
        jb_2 = new javax.swing.JButton();
        jb_3 = new javax.swing.JButton();
        jb_4 = new javax.swing.JButton();
        jb_5 = new javax.swing.JButton();
        jb_menos = new javax.swing.JButton();
        jb_6 = new javax.swing.JButton();
        jb_vezes = new javax.swing.JButton();
        jb_9 = new javax.swing.JButton();
        jb_8 = new javax.swing.JButton();
        jb_7 = new javax.swing.JButton();
        jb_dividir = new javax.swing.JButton();
        jb_ponto = new javax.swing.JButton();
        tf_calculo = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("AssisTec - Calculadora");
        setResizable(false);
        getContentPane().setLayout(null);

        jb_0.setBackground(new java.awt.Color(255, 255, 255));
        jb_0.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_0.setText("0");
        jb_0.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_0.setBorderPainted(false);
        jb_0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_0ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_0);
        jb_0.setBounds(10, 180, 60, 40);

        jb_igual.setBackground(new java.awt.Color(255, 255, 255));
        jb_igual.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_igual.setText("=");
        jb_igual.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_igual.setBorderPainted(false);
        jb_igual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_igualActionPerformed(evt);
            }
        });
        getContentPane().add(jb_igual);
        jb_igual.setBounds(130, 180, 60, 40);

        jb_mais.setBackground(new java.awt.Color(255, 255, 255));
        jb_mais.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_mais.setText("+");
        jb_mais.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_mais.setBorderPainted(false);
        jb_mais.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_maisActionPerformed(evt);
            }
        });
        getContentPane().add(jb_mais);
        jb_mais.setBounds(190, 180, 60, 40);

        jb_limpar.setBackground(new java.awt.Color(255, 255, 255));
        jb_limpar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_limpar.setText("C");
        jb_limpar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_limpar.setBorderPainted(false);
        jb_limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_limparActionPerformed(evt);
            }
        });
        getContentPane().add(jb_limpar);
        jb_limpar.setBounds(190, 10, 60, 50);

        jb_1.setBackground(new java.awt.Color(255, 255, 255));
        jb_1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_1.setText("1");
        jb_1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_1.setBorderPainted(false);
        jb_1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_1ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_1);
        jb_1.setBounds(10, 140, 60, 40);

        jb_2.setBackground(new java.awt.Color(255, 255, 255));
        jb_2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_2.setText("2");
        jb_2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_2.setBorderPainted(false);
        jb_2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_2ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_2);
        jb_2.setBounds(70, 140, 60, 40);

        jb_3.setBackground(new java.awt.Color(255, 255, 255));
        jb_3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_3.setText("3");
        jb_3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_3.setBorderPainted(false);
        jb_3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_3ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_3);
        jb_3.setBounds(130, 140, 60, 40);

        jb_4.setBackground(new java.awt.Color(255, 255, 255));
        jb_4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_4.setText("4");
        jb_4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_4.setBorderPainted(false);
        jb_4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_4ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_4);
        jb_4.setBounds(10, 100, 60, 40);

        jb_5.setBackground(new java.awt.Color(255, 255, 255));
        jb_5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_5.setText("5");
        jb_5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_5.setBorderPainted(false);
        jb_5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_5ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_5);
        jb_5.setBounds(70, 100, 60, 40);

        jb_menos.setBackground(new java.awt.Color(255, 255, 255));
        jb_menos.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_menos.setText("-");
        jb_menos.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_menos.setBorderPainted(false);
        jb_menos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_menosActionPerformed(evt);
            }
        });
        getContentPane().add(jb_menos);
        jb_menos.setBounds(190, 140, 60, 40);

        jb_6.setBackground(new java.awt.Color(255, 255, 255));
        jb_6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_6.setText("6");
        jb_6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_6.setBorderPainted(false);
        jb_6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_6ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_6);
        jb_6.setBounds(130, 100, 60, 40);

        jb_vezes.setBackground(new java.awt.Color(255, 255, 255));
        jb_vezes.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_vezes.setText("*");
        jb_vezes.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_vezes.setBorderPainted(false);
        jb_vezes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_vezesActionPerformed(evt);
            }
        });
        getContentPane().add(jb_vezes);
        jb_vezes.setBounds(190, 100, 60, 40);

        jb_9.setBackground(new java.awt.Color(255, 255, 255));
        jb_9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_9.setText("9");
        jb_9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_9.setBorderPainted(false);
        jb_9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_9ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_9);
        jb_9.setBounds(130, 60, 60, 40);

        jb_8.setBackground(new java.awt.Color(255, 255, 255));
        jb_8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_8.setText("8");
        jb_8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_8.setBorderPainted(false);
        jb_8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_8ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_8);
        jb_8.setBounds(70, 60, 60, 40);

        jb_7.setBackground(new java.awt.Color(255, 255, 255));
        jb_7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jb_7.setText("7");
        jb_7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_7.setBorderPainted(false);
        jb_7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_7ActionPerformed(evt);
            }
        });
        getContentPane().add(jb_7);
        jb_7.setBounds(10, 60, 60, 40);

        jb_dividir.setBackground(new java.awt.Color(255, 255, 255));
        jb_dividir.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_dividir.setText("/");
        jb_dividir.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_dividir.setBorderPainted(false);
        jb_dividir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_dividirActionPerformed(evt);
            }
        });
        getContentPane().add(jb_dividir);
        jb_dividir.setBounds(190, 60, 60, 40);

        jb_ponto.setBackground(new java.awt.Color(255, 255, 255));
        jb_ponto.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jb_ponto.setText(".");
        jb_ponto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_ponto.setBorderPainted(false);
        jb_ponto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_pontoActionPerformed(evt);
            }
        });
        getContentPane().add(jb_ponto);
        jb_ponto.setBounds(70, 180, 60, 40);

        tf_calculo.setBackground(new java.awt.Color(78, 78, 78));
        tf_calculo.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        tf_calculo.setForeground(new java.awt.Color(255, 255, 255));
        tf_calculo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        getContentPane().add(tf_calculo);
        tf_calculo.setBounds(10, 10, 180, 50);

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fundo.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 260, 260);

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jb_menosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_menosActionPerformed
        String Botao = jb_menos.getText();
        pegarOperador(Botao);
    }//GEN-LAST:event_jb_menosActionPerformed

    private void jb_limparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_limparActionPerformed
        tf_calculo.setText("");
    }//GEN-LAST:event_jb_limparActionPerformed

    private void jb_1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_1ActionPerformed
        String B1 = tf_calculo.getText() + jb_1.getText();
        tf_calculo.setText(B1);
    }//GEN-LAST:event_jb_1ActionPerformed

    private void jb_2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_2ActionPerformed
        String B2 = tf_calculo.getText() + jb_2.getText();
        tf_calculo.setText(B2);
    }//GEN-LAST:event_jb_2ActionPerformed

    private void jb_3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_3ActionPerformed
        String B3 = tf_calculo.getText() + jb_3.getText();
        tf_calculo.setText(B3);
    }//GEN-LAST:event_jb_3ActionPerformed

    private void jb_4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_4ActionPerformed
        String B4 = tf_calculo.getText() + jb_4.getText();
        tf_calculo.setText(B4);
    }//GEN-LAST:event_jb_4ActionPerformed

    private void jb_5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_5ActionPerformed
        String B5 = tf_calculo.getText() + jb_5.getText();
        tf_calculo.setText(B5);
    }//GEN-LAST:event_jb_5ActionPerformed

    private void jb_6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_6ActionPerformed
        String B6 = tf_calculo.getText() + jb_6.getText();
        tf_calculo.setText(B6);
    }//GEN-LAST:event_jb_6ActionPerformed

    private void jb_7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_7ActionPerformed
        String B7 = tf_calculo.getText() + jb_7.getText();
        tf_calculo.setText(B7);
    }//GEN-LAST:event_jb_7ActionPerformed

    private void jb_8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_8ActionPerformed
        String B8 = tf_calculo.getText() + jb_8.getText();
        tf_calculo.setText(B8);
    }//GEN-LAST:event_jb_8ActionPerformed

    private void jb_9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_9ActionPerformed
        String B9 = tf_calculo.getText() + jb_9.getText();
        tf_calculo.setText(B9);
    }//GEN-LAST:event_jb_9ActionPerformed

    private void jb_0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_0ActionPerformed
        String B0 = tf_calculo.getText() + jb_0.getText();
        tf_calculo.setText(B0);
    }//GEN-LAST:event_jb_0ActionPerformed

    private void jb_maisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_maisActionPerformed
        String Botao = jb_mais.getText();
        pegarOperador(Botao);
    }//GEN-LAST:event_jb_maisActionPerformed

    private void jb_igualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_igualActionPerformed
        switch (Operador_Matematico) {
            case '+':
                Operacao2 = Operacao1 + Double.parseDouble(tf_calculo.getText());
                break;

            case '-':
                Operacao2 = Operacao1 - Double.parseDouble(tf_calculo.getText());
                break;

            case '/':
                Operacao2 = Operacao1 / Double.parseDouble(tf_calculo.getText());
                break;

            case '*':
                Operacao2 = Operacao1 * Double.parseDouble(tf_calculo.getText());
                break;
        }
        tf_calculo.setText(Double.toString(Operacao2));
        Operacao1 = 0;

    }//GEN-LAST:event_jb_igualActionPerformed

    private void jb_dividirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_dividirActionPerformed
        String Botao = jb_dividir.getText();
        pegarOperador(Botao);
    }//GEN-LAST:event_jb_dividirActionPerformed

    private void jb_vezesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_vezesActionPerformed
        String Botao = jb_vezes.getText();
        pegarOperador(Botao);
    }//GEN-LAST:event_jb_vezesActionPerformed

    private void jb_pontoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_pontoActionPerformed
        String Botao = tf_calculo.getText() + jb_ponto.getText();
        tf_calculo.setText(Botao);
    }//GEN-LAST:event_jb_pontoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Tela_Calc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Tela_Calc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Tela_Calc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Tela_Calc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Tela_Calc().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton jb_0;
    private javax.swing.JButton jb_1;
    private javax.swing.JButton jb_2;
    private javax.swing.JButton jb_3;
    private javax.swing.JButton jb_4;
    private javax.swing.JButton jb_5;
    private javax.swing.JButton jb_6;
    private javax.swing.JButton jb_7;
    private javax.swing.JButton jb_8;
    private javax.swing.JButton jb_9;
    private javax.swing.JButton jb_dividir;
    private javax.swing.JButton jb_igual;
    private javax.swing.JButton jb_limpar;
    private javax.swing.JButton jb_mais;
    private javax.swing.JButton jb_menos;
    private javax.swing.JButton jb_ponto;
    private javax.swing.JButton jb_vezes;
    private javax.swing.JTextField tf_calculo;
    // End of variables declaration//GEN-END:variables

}
